package azcat.planner.materials;

public class NeededMaterialsEstimator implements java.io.Serializable{
	
	/**
	 * 
	 */
	private static final long serialVersionUID = -4252204810449781060L;

	public NeededMaterialsEstimator(){
		
	}
	/**
	 * This method calculates the volume of the piece and the material, and then calculates how many pieces can be obtained.
	 * @param largo is the length
	 * @param ancho is the width
	 * @param espesor is the  depth. This can only be zero for 2D pieces other wise it must be > 0
	 * @param mat
	 * @return
	 */
	public float estimatePiecesPerBlock(float largo, float ancho, float espesor, Material mat){
		float pieceVol;
		float matVol;
		if(mat.getDepth() <= 0){//calculates area
			if(largo > 0 && ancho > 0){
				pieceVol = largo*ancho;
				matVol = mat.getLength()*mat.getWidth();
				return matVol/pieceVol;
			}
			else{
				return 0;
			}
		}
		else{
			pieceVol = largo*ancho*espesor;//calculates volume
			matVol = mat.getLength()*mat.getWidth()*mat.getDepth();
			return matVol/pieceVol;
		}		
	}
	
	public float estimateBlocksNeeded(Material mat){		
		return  (mat.getTotalComps()/mat.getPiecesxBlock());
	}
	
	public int estimateTotalComponents(int components, int totalPieces){		
		return components * totalPieces;
	}
}
